package com.example.mapp;

import com.example.entity.check.SelfCheck;
import com.example.mapp.buildSql.SelfCheckMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by simon on 2018/5/29.
 */
@Mapper
public interface SelfCheckMapp {

    @Insert(" insert into self_check (ELEVATOR_ID,MAINT_PARTY_ID,MAINT_PARTY_NAME,MAINT_USER_ID" +
            ",MAINT_USER_NAME,ELEVATOR_NUM," +
            "PIC1,PIC2,PIC3" +
            ",SAFE_USER_SIGN,SAFE_USER_SIGN_TIME,MAINT_USER_SIGN,MAINT_USER_SIGN_TIME,IS_PASS,CHECK_TIME) value" +
            " (#{elevatorId},#{maintPartyId},#{maintPartyName},#{maintUserId},#{maintUserName},#{elevatorNum}," +
            "#{pic1},#{pic2},#{pic3}," +
            "#{safeUserSign},#{safeUserSignTime},#{maintUserSign}" +
            ",#{maintUserSignTime},#{isPass},#{checkTime})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    public int add(SelfCheck selfCheck) throws Exception;

    @SelectProvider(type = SelfCheckMappSql.class, method = "queryList")
    List<SelfCheck> queryList(SelfCheck selfCheck) throws Exception;

    @Select("select *" +
            " from self_check where id=#{id}")
    SelfCheck queryById(String id) throws Exception;

}
